<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;

class OnePanelAPIController extends Controller
{
    public function getInstalledList(){
        $scheme="http://";
        $server="120.26.138.80:21139/api/v2";
        $api="/apps/installed/list";
        $url=$scheme.$server.$api;
        $getter=$this->generateHeader();
        $response=$getter->get($url);
        return $response->body();
    }
    //
    private function generateHeader(){
        $time=time();
        $secret=env("1PANEL_SECRET");
        $token=md5('1panel'.$secret.$time);
        return Http::withHeaders([
            '1Panel-Token' =>$token,
            '1Panel-Timestamp' => $time
        ]);
    }
}
